<?php
namespace Home\Controller;
use Think\Controller;
class YueziController extends Controller {
    //$id月子中心id  tid自增的id
    public function index($id,$tid=0){
        if($tid==0){
            $where="yid=".$id;
        }else{
            $where="id=".$tid;
        }
        $package=D("Carecenter_package");

//        $add= end($result);
        $result=$package->where($where)->find();
        $this->assign('result',$result);
        $this->display();
    }


    public function index_en($id,$tid=0){
        if($tid==0){
            $where="yid=".$id;
        }else{
            $where="id=".$tid;
        }
        $package=D("Carecenter_package");

        $result=$package->where($where)->find();

        if($result['name_en']=="" && $result['des_en']==""){
          $result['name_en']=$result['name_cn'];
          $result['des_en']=$result['des_cn'];
          $result['peibi_en']= $result['peibi_cn'];
          $result['remark_en']=$result['remark_cn'];
            $this->assign('result',$result);
        }else{
            $this->assign('result',$result);
        }


        $this->display();
    }
    //月子中心id
    public function lists($id){
        if($id!=0){
            $where="yid=".$id;
        }
        $package=D("Carecenter_package");
        $result=$package->where($where)->field("id,name_cn")->select();
        $this->assign('result',$result);
        $this->display();
    }


    //月子中心id
    public function lists_en($id){
        if($id!=0){
            $where="yid=".$id;
        }
        $package=D("Carecenter_package");
        $result=$package->where($where)->field("id,name_en,name_cn")->select();
        foreach($result as $key=>&$value){
            if($value['name_en']==""){
                $data['name_en']=$value['name_cn'];
                $data['id']=$value['id'];
            }
        }

        $this->assign('result',$result);

        $this->display();
    }

}